home *** CD-ROM | disk | FTP | other *** search
Text File | 1990-04-30 | 24.8 KB | 736 lines | [TEXT/MPS ] |
- {[j=20/53/1$] Pasmat Options}
-
- {--------------------------------------------------------------------------------------------------}
- {$S AOpen}
-
- PROCEDURE TOffscreen.IOffscreen;
-
- { Initialize the offscreen world. This NILs out our instance variables and calls IObject. }
-
- BEGIN
- fOldPort := NIL;
- fOldDevice := NIL;
- SELF.IObject;
- END;
-
- {--------------------------------------------------------------------------------------------------}
- {$S ARes}
-
- PROCEDURE TOffscreen.ChangeCTFlag(whichBit: Integer; whichWay: Boolean);
-
- { Sets the state of a flag in the ctFlags field of our offscreen world. This is needed in at
- least one case, where we have to clear bit 14 before saving the color table to disk. This
- routine will either clear or set the bit. }
-
- VAR
- fred: LongInt;
-
- BEGIN
- fred := GetOffPort^.portPixMap^^.pmTable^^.ctFlags;
- IF whichWay = kClearFlag THEN
- BClr(fred, whichBit)
- ELSE
- BSet(fred, whichBit);
- GetOffPort^.portPixMap^^.pmTable^^.ctFlags := fred;
- END;
-
- {--------------------------------------------------------------------------------------------------}
- {$S ARes}
-
- FUNCTION TOffscreen.GetOffDevice: GDHandle;
-
- { Return a GDHandle to the offscreen device. TOffScreen doesn’t manage any offscreen
- elements itself, so it can’t return anything useful here. The main intent is to have an
- abstract method that we can override that WILL return somthing. If not overridden, this
- method complains and returns the device handle of the Main Device as default so that we
- don’t die if it isn’t overridden. }
-
- BEGIN
- IF qDebug THEN BEGIN
- GetOffDevice := GetMainDevice;
- ProgramBreak(
- 'TOffscreen.GetOffDevice: Not overridden. Returning GetMainDevice result.'
- );
- END;
- END;
-
- {--------------------------------------------------------------------------------------------------}
- {$S ARes}
-
- FUNCTION TOffscreen.GetOffPixBase: Ptr;
-
- { Return a Ptr to the offscreen buffer block. TOffScreen doesn’t manage any offscreen
- elements itself, so it can’t return anything useful here. The main intent is to have an
- abstract method that we can override that WILL return somthing. If not overridden, this
- method complains and returns the base address of “thePort” as default so that we don’t die
- if it isn’t overridden. }
-
- BEGIN
- IF qDebug THEN BEGIN
- IF BOr($0C000, CGrafPtr(thePort)^.portVersion) = 0 THEN BEGIN
- { old style B&W grafPort }
- GetOffPixBase := thePort^.portBits.baseAddr;
- END
- ELSE BEGIN
- { new style color CGrafPort }
- GetOffPixBase := CGrafPtr(thePort)^.portPixMap^^.baseAddr;
- END;
- ProgramBreak(
- 'TOffscreen.GetOffPixBase: Not overridden. Returning thePort.baseAddr.'
- );
- END;
- END;
-
- {--------------------------------------------------------------------------------------------------}
- {$S ARes}
-
- FUNCTION TOffscreen.GetOffPort: CGrafPtr;
-
- { Return a CGrafPtr to the offscreen port. TOffScreen doesn’t manage any offscreen elements
- itself, so it can’t return anything useful here. The main intent is to have an abstract
- method that we can override that WILL return somthing. If not overridden, this method
- complains and returns ‘thePort’ as default so that we don’t die if it isn’t overridden. }
-
- BEGIN
- IF qDebug THEN BEGIN
- GetOffPort := CGrafPtr(thePort);
- ProgramBreak('TOffscreen.GetOffPort: Not overridden. Returning “thePort”.');
- END;
- END;
-
- {--------------------------------------------------------------------------------------------------}
- {$S ARes}
-
- FUNCTION TOffscreen.GetOldDevice: GDHandle;
-
- { Return a GDHandle to the saved device. }
-
- BEGIN
- GetOldDevice := fOldDevice;
- END;
-
- {--------------------------------------------------------------------------------------------------}
- {$S ARes}
-
- FUNCTION TOffscreen.GetOldPort: GrafPtr;
-
- { Return a GrafPtr to the saved port. }
-
- BEGIN
- GetOldPort := fOldPort;
- END;
-
- {--------------------------------------------------------------------------------------------------}
- {$S ARes}
-
- PROCEDURE TOffscreen.LockThePixels;
-
- { For 32BCQD support. Does nothing by default. Should be overridden if you are using the
- 32-bit Color QuickDraw routines for offscreen support, and need to lock down your pixels
- before accessing them. }
-
- BEGIN
- END;
-
- {--------------------------------------------------------------------------------------------------}
- {$S ARes}
-
- PROCEDURE TOffscreen.PreDraw;
-
- { Call this method to save off the current drawing world and swap in the offscreen drawing
- world. It calls SaveOldWord and SetUpOffWorld to do all the dirty work. Since these
- methods do nothing in TOffScreen, you must override them in your sub-class. }
-
- BEGIN
- SELF.SaveOldWorld;
- SELF.SetupOffWorld;
- END;
-
- {--------------------------------------------------------------------------------------------------}
- {$S ARes}
-
- PROCEDURE TOffscreen.PostDraw;
-
- { Reverses the effects of PreDraw by restoring the previously save port and device. }
-
- BEGIN
- SELF.RestoreOldWorld;
- END;
-
- {--------------------------------------------------------------------------------------------------}
- {$S ARes}
-
- PROCEDURE TOffscreen.RestoreOldWorld;
-
- BEGIN
- SetGDevice(fOldDevice);
- SetPort(fOldPort);
- fOldDevice := NIL; { Clear these out so that if anyone calls
- GetOldDevice or GetOldPort they’ll get
- NIL, meaning that we aren’t
- offscreening right now. }
- fOldPort := NIL;
- END;
-
- {--------------------------------------------------------------------------------------------------}
- {$S ARes}
-
- PROCEDURE TOffscreen.SaveOldWorld;
-
- BEGIN
- fOldDevice := GetGDevice;
- {$Push} {$H-}
- GetPort(fOldPort);
- {$Pop}
- END;
-
- {--------------------------------------------------------------------------------------------------}
- {$S ARes}
-
- PROCEDURE TOffscreen.SetupOffWorld;
-
- BEGIN
- IF qDebug THEN
- ProgramBreak('TOffscreen.SetupOffWorld: Gotta Override me!');
- END;
-
- {--------------------------------------------------------------------------------------------------}
- {$S ARes}
-
- PROCEDURE TOffscreen.UnlockThePixels;
-
- { For 32BCQD support. Does nothing by default. Should be overridden if you are using the
- 32-bit Color QuickDraw routines for offscreen support, and need to unlock your pixels
- after accessing them. }
-
- BEGIN
- END;
-
- {--------------------------------------------------------------------------------------------------}
- {$S AFields}
-
- PROCEDURE TOffscreen.Fields(PROCEDURE DoToField(fieldName: Str255; fieldAddr: Ptr;
- fieldType: Integer)); OVERRIDE;
-
- BEGIN
- DoToField('TOffscreen', NIL, bClass);
- DoToField('fOldDevice', @fOldDevice, bHandle);
- DoToField('fOldPort', @fOldPort, bGrafPtr);
-
- INHERITED Fields(DoToField);
- END;
-
- {--------------------------------------------------------------------------------------------------}
- {$S AOpen}
-
- PROCEDURE TOldGrossOffscreen.IOldGrossOffscreen(offBounds: Rect; itsColors: CTabHandle);
-
- { Create and initialize an offscreen drawing environment using the routines described in
- Inside Mac V. The offscreen world size is specified by “offBound”, and uses the colors in
- itsColors. It makes a copy of the table. }
-
- CONST
-
- { These are the flags we pass to NewGDevice when creating our offscreen device. }
-
- kGDFlags = 2 ** screenActive + 2 ** noDriver + 2 **
- ramInit + 2 ** gdDevType;
- kNoDriver = 0; { passed to NewGDevice. }
- kModeForNoDriver = - 1; { passed to NewGDevice. }
-
- VAR
- oldPerm: Boolean;
- dummy: Boolean; { dummy result for PermAllocation. }
- docW, docH: LongInt;
- fi: FailInfo;
- anOffDevice: GDHandle;
- aBuffPointer: Ptr;
-
- { This is the error handler for when we get errors while making a new GWorld,
- typically like running out of memory. Since we call the Free method for the
- TOffscreen, we don’t have to clean things up ourselves here. Just set
- allocation back to normal (for the error message itself), set the drawing
- environment back to normal, call Free, and return. }
-
- PROCEDURE DeathOffscreen(error: OSErr; message: LongInt);
-
- BEGIN
- oldPerm := PermAllocation(oldPerm); { Set memory back to previous. }
- SELF.RestoreOldWorld;
- SELF.Free;
- END;
-
- BEGIN
-
- { Set all these to NIL. If there is an error, then we need to free ourselves.
- In that case, we don’t want these variables holding garbage. If they do, that
- garbage may look enough like the real thing, and the Dispose routines will
- try to de-allocate memory that was never allocated to begin with… }
-
- fOffPort := NIL;
- fOffDevice := NIL;
- fBigBuff := NIL;
-
- { Allow our base class to initialize itself. }
-
- SELF.IOffscreen;
-
- { Prepare for failure. The memory used creating the view must be out of permanent
- memory so call PermAllocation to make it so. Set up an error handler that will
- set it back in case we can’t get any of that memory. We also try to restore the
- drawing world to something useful, so make sure we save a consistant world by
- calling SaveOldWorld. }
-
- SELF.SaveOldWorld;
- oldPerm := PermAllocation(TRUE);
- CatchFailures(fi, DeathOffscreen); { any failures must be cleaned up. }
-
- { Let’s set up the size of the rectangle we are using for the document. Don’t
- forget that the width must be an even number, so we round it up. }
-
- WITH offBounds DO BEGIN
- docW := (((right - left) + 1) DIV 2) * 2;
- docH := bottom - top;
- END;
-
- { Now try to set up the offscreen pixMap (color). If we fail we have to split,
- and we might since we may not have 500K or more for the pixMap. Each document
- on screen will have a full pixMap for it. Allocate a full buffer in 8 bit
- depth, its size based on the bounding rectangle passed in to us. Also make it
- into a color port so we can draw into it normally and use it as a source for
- CopyBits. Requires 8 bits deep for the number of colors, and sets up a buffer
- with that in mind, that is full docRect size with one byte per pixel as 8 bit
- mode. This is width * height. 8 bits/byte. }
-
- aBuffPointer := NewPtr(docW * docH);
- FailNIL(aBuffPointer); { couldn’t get it we die. }
- fBigBuff := aBuffPointer;
-
- { OK, now we get wacko. We need to create our own gDevice, since we want to
- have an offscreen device. This needs to be done so that we have full control
- over the color table used, in order to save full 8 bit documents, even if we
- aren’t in 8 bit mode when we save. So... We will start by creating a
- NewGDevice, that will allocate a temporary ITable, and PixMap with partial
- colorTable; change the fields of the device’s pixMap to our bitMap, with
- right size, depth, and rowbytes; init the fields of that device, including
- changing the color table to our color table created from our clut; set that
- gDevice as the current one; then do the OpenCPort which will use the current
- gDevice to make its PixMap and color table. When we go to draw or save the
- data in the offscreen buffer, we need to set the current device so we use our
- color table, making all the colors come out right. }
-
- { Now we need to do the piece to make an offscreen gDevice that is not
- connected to the screen. Allocate a new one, with stub pixMap. }
-
- anOffDevice := NewGDevice(kNoDriver, kModeForNoDriver);
- FailNIL(anOffDevice); { If we failed, error out. }
- fOffDevice := anOffDevice;
-
- { Now init all the fields we can in the gDevice Record, since it comes
- uninitialized. }
-
- LockHandleHigh(Handle(fOffDevice));
- WITH fOffDevice^^ DO BEGIN
- gdID := 0; { no ID for search & complement procs }
- gdType := clutType; { color table type fer sure. }
-
- { Get the color table for the offscreen gDevice. This is a copy of the global
- color table we created early on. }
-
- DisposCTable(gdPMap^^.pmTable); { kill the stub that is there. }
- gdPMap^^.pmTable := itsColors; { make a copy of our global color table.
- }
- FailOSErr(HandToHand(Handle(gdPMap^^.pmTable))); { and stick it into this gDevice
- too. }
-
- { Build a new iTable for this device, based on the new color table. 3 bit res
- to save on memory since we don’t need a big iTable for our stuff. }
-
- MakeITable(gdPMap^^.pmTable, gdITable, 3);
- FailOSErr(QDError); { no memory, we can leave here. }
-
- gdResPref := 3; { preferred resolution in table. }
- gdSearchProc := NIL; { no search proc. }
- gdCompProc := NIL; { no complement proc. }
-
- { Set the gdFlags to be: color, ramInit, noDriver, screenActive }
-
- gdFlags := kGDFlags;
-
- WITH gdPMap^^ DO BEGIN
-
- { Now set up the fields in the offscreen PixMap correctly. }
-
- baseAddr := fBigBuff; { The base address is our buffer. }
- bounds := offBounds; { bounding rectangle to our device. }
-
- { One byte per pixel horizontally is rowBytes. + $8000 to make it color port. }
-
- {$Push} {$OV-} { Have to turn off overflow checking, or
- else Pascal complains that you’re
- trying to put a Longint into a Integer
- field. }
- rowBytes := BOr(docW, $00008000);
- {$Pop}
- pixelSize := 8;
- cmpCount := 1;
- cmpSize := 8;
- END; { WITH gdPMap^^ }
-
- gdRect := offBounds; { the bounding rectangle for gDevice,
- too. }
- END; { WITH fOffDevice }
-
- { Now unlock the gDevice handle. The system can use it unlocked as well as
- locked so we try to help avoid fragmentation. }
-
- HUnLock(Handle(fOffDevice));
-
- { Yow, that was rough. Now we have a fully initialized gDevice offscreen with
- its own color table. All color mapping should be done using that color table,
- and the drawing we do to it should make the saved pictures save that color
- table too. Set to our new device so we OpenCPort with all new parameters. This
- is safe, because we saved the old device when we entered this routine. }
-
- SetGDevice(fOffDevice);
-
- { After all of that, we have a gDevice which is complete. It has the color
- table we want associated with it from the CLUT. It has the right
- portBits.baseAddr, and the right size. It is complete, except that we can’t
- draw into it using normal calls. We thus need to make a port that we can use.
- We have set the gDevice to be the one we just created, and when we OpenCPort
- we will get a copy of the fields we just set up in our new gDevice. The port
- is simply an interface into our gDevice for drawing. Allocate a port record
- on the heap as a pointer (permanent memory usage). After it lives, though we
- want to check if we have no more reserve, and if so we must bag this
- document. }
-
- fOffPort := CGrafPtr(NewPtr(SizeOf(CGrafPort)));
- FailNIL(fOffPort); { didn’t get it, means we die. }
-
- OpenCPort(fOffPort); { make a new port offscreen. }
- FailNoReserve; { Make reserve, die if we can’t }
-
- { QuickDraw is most obnoxious about making a port that is bigger than the
- screen, so we need to modify the visRgn to make it as big as our full page
- document. It is OK to change this port’s visRgn since we own it offscreen.
- This is in case we are opening a document made on a different computer with a
- bigger screen. Also, you may have seen in Inside Mac the notice that “the
- visRgn has no effect on images that aren’t displayed on the screen.” Don’t
- believe it, because it DOES affect offscreen images. }
-
- RectRgn(fOffPort^.visRgn, offBounds);
-
- { Go whap on the other pieces of the port record to set it up to be offscreen. }
-
- fOffPort^.portRect := offBounds;
-
- { OK, we have a nice new color port that is offscreen. It has a fancy color
- table that came from the clut that will be used for the owning window. It is
- 8 bits deep, has 256 colors in its color table and has a rect the size passed
- in. It has no pieces that are related to the main gDevice, so we shouldn’t
- alter that by drawing in this port. }
-
- { Clear the error handler chain, we don’t make any more dangerous requests. Set
- the memory allocation to what we started with. }
-
- Success(fi);
- oldPerm := PermAllocation(oldPerm);
-
- { Swap over to our offscreen world so that we can clear it out. We swap over to
- it with a simple SetupOffWorld call, which is OK because we saved the
- original drawing environment at the beginning on this procedure with
- SaveOldWorld. }
-
- SELF.SetupOffWorld;
- EraseRect(offBounds); { clear the bits. }
- SELF.RestoreOldWorld;
-
- END; { IOldGrossOffscreen }
-
- {--------------------------------------------------------------------------------------------------}
- {$S AClose}
-
- PROCEDURE TOldGrossOffscreen.Free; OVERRIDE;
-
- BEGIN
-
- { Kill the bits for the offscreen bitMap if they were allocated. }
-
- DisposIfPtr(fBigBuff);
-
- { Close the port: remove from portList, kill visRgn and clipRgn, kill the
- penPixPat and fill PixPat and back PixPat, kill PixMap handle, kill grafVars
- handle. }
-
- IF fOffPort <> NIL THEN BEGIN
- CloseCPort(fOffPort);
- DisposPtr(Ptr(fOffPort));
- END;
-
- { DisposGDevice does: kills the ITable, kills Cursor expanded data and mask if
- nonzero, calls DisposPixMap if gdPMap is nonzero, then disposes the gDevice
- handle itself. DisposPixMap kills the colorTable and the pixMap record. }
-
- IF fOffDevice <> NIL THEN
- DisposGDevice(fOffDevice);
-
- INHERITED Free;
-
- END;
-
- {--------------------------------------------------------------------------------------------------}
- {$S ARes}
-
- FUNCTION TOldGrossOffscreen.GetOffDevice: GDHandle; OVERRIDE;
-
- BEGIN
- GetOffDevice := fOffDevice;
- END;
-
- {--------------------------------------------------------------------------------------------------}
- {$S ARes}
-
- FUNCTION TOldGrossOffscreen.GetOffPixBase: Ptr; OVERRIDE;
-
- BEGIN
- GetOffPixBase := fBigBuff;
- END;
-
- {--------------------------------------------------------------------------------------------------}
- {$S ARes}
-
- FUNCTION TOldGrossOffscreen.GetOffPort: CGrafPtr; OVERRIDE;
-
- BEGIN
- GetOffPort := CGrafPtr(fOffPort);
- END;
-
- {--------------------------------------------------------------------------------------------------}
- {$S ARes}
-
- PROCEDURE TOldGrossOffscreen.SetupOffWorld; OVERRIDE;
-
- { The default SetupOffWorld doesn’t do anything because it doesn’t know what form our
- offscreen management takes. So we have to override it here. We set up our offscreen world
- with simple SetGDevice and SetPort calls. }
-
- BEGIN
- SetGDevice(fOffDevice);
- SetPort(GrafPtr(fOffPort));
- END;
-
- {--------------------------------------------------------------------------------------------------}
- {$S AFields}
-
- PROCEDURE TOldGrossOffscreen.Fields(PROCEDURE DoToField(fieldName: Str255; fieldAddr: Ptr;
- fieldType: Integer)); OVERRIDE;
-
- BEGIN
- DoToField('TOldGrossOffscreen', NIL, bClass);
- DoToField('fBigBuff', @fBigBuff, bPointer);
- DoToField('fOffDevice', @fOffDevice, bHandle);
- DoToField('fOffPort', @fOffPort, bGrafPtr);
-
- INHERITED Fields(DoToField);
- END;
-
- {--------------------------------------------------------------------------------------------------}
- {$S AOpen}
-
- PROCEDURE TNewCoolOffscreen.INewCoolOffscreen(offBounds: Rect; itsColors: CTabHandle);
-
- { Create and initialize an offscreen drawing environment using the 32-bit Color QuickDraw
- routines. The offscreen world size is specified by “offBound”, and uses the colors in
- itsColors. It makes a copy of the table. }
-
- CONST
- kBitDepth = 8;
-
- VAR
- anOffWorld: GWorldPtr;
- oldPerm: Boolean;
- fi: FailInfo;
- auxDev: GDHandle;
-
- { This is the error handler for when we get errors while making a new GWorld,
- typically like running out of memory. Since we call the Free method for the
- TOffscreen, we don’t have to clean things up ourselves here. Just set
- allocation back to normal (for the error message itself), set the drawing
- environment back to normal, call Free, and return. }
-
- PROCEDURE DeathOffscreen(error: OSErr; message: LongInt);
-
- BEGIN
- oldPerm := PermAllocation(oldPerm);
- SELF.RestoreOldWorld;
- SELF.Free;
- END;
-
- BEGIN
-
- { Set this to NIL. If there is an error, then we need to free ourselves.
- In that case, we don’t want our variables holding garbage. If they do, that
- garbage may look enough like the real thing, and the Dispose routines will
- try to de-allocate memory that was never allocated to begin with… }
-
- fOffWorld := NIL;
-
- { Allow our base class to initialize itself. }
-
- SELF.IOffscreen;
-
- { Prepare for failure. The memory used creating the view must be out of permanent
- memory so call PermAllocation to make it so. Set up an error handler that will
- set it back in case we can’t get any of that memory. We also try to restore the
- drawing world to something useful, so make sure we save a consistant world by
- calling SaveOldWorld. }
-
- SELF.SaveOldWorld;
- oldPerm := PermAllocation(TRUE);
- CatchFailures(fi, DeathOffscreen); { any failures must be cleaned up. }
-
- { Time to make the big, bad NewGWorld call. This does everything:
-
- • anOffWorld: a VAR parameter. NewGWorld returns a reference to our
- GWorld in this.
- • k8Bits: desired depth of our offscreen GWorld
- • offBounds: a Rect used for the bounds, the portRect, the gdRect
- • itsColors: a CTable used for color indexing
- • NIL: a GDHandle if we wanted to provid one of our own
- • []: there are two flags that we could have passed here. By passing the
- empty set, we are saying that we don’t want the PixMap purgable, and
- that we want NewGWorld to make a GDevice for us. Since we’re basically
- lazy (all programmer’s are), that’s fine with us.
-
- NewGWorld returns a QDErr if it can’t cut the mustard. }
-
- FailOSErr(NewGWorld(anOffWorld, kBitDepth, offBounds, itsColors, NIL, []));
- fOffWorld := anOffWorld;
-
- auxDev := GetGWorldDevice(fOffWorld);
- MakeITable(itsColors, auxDev^^.gdITable, 3); { 3 bits to save room }
- FailOSErr(QDError); { sad, he says }
-
- { Clear the error handler chain, we don’t make any more dangerous requests. Set
- the memory allocation to what we started with. }
-
- oldPerm := PermAllocation(oldPerm);
- Success(fi);
-
- { Swap over to our offscreen world so that we can clear it out. We swap over to
- it with a simple SetupOffWorld call, which is OK because we saved the
- original drawing environment at the beginning on this procedure with
- SaveOldWorld. }
-
- SELF.SetupOffWorld;
- EraseRect(fOffWorld^.portRect); { clear the bits. }
- SELF.UnlockThePixels;
- SELF.RestoreOldWorld;
-
- {SetPalette(WindowPtr(GetOffPort), gPalette, kDontWantUpdates);}
- END;
-
- {--------------------------------------------------------------------------------------------------}
- {$S AClose}
-
- PROCEDURE TNewCoolOffscreen.Free; OVERRIDE;
-
- BEGIN
- IF fOffWorld <> NIL THEN
- DisposeGWorld(fOffWorld);
- INHERITED Free;
- END;
-
- {--------------------------------------------------------------------------------------------------}
- {$S ARes}
-
- FUNCTION TNewCoolOffscreen.GetOffDevice: GDHandle; OVERRIDE;
-
- BEGIN
- GetOffDevice := GetGWorldDevice(fOffWorld);
- END;
-
- {--------------------------------------------------------------------------------------------------}
- {$S ARes}
-
- FUNCTION TNewCoolOffscreen.GetOffPixBase: Ptr; OVERRIDE;
-
- BEGIN
- GetOffPixBase := GetPixBaseAddr(fOffWorld^.portPixMap);
- END;
-
- {--------------------------------------------------------------------------------------------------}
- {$S ARes}
-
- FUNCTION TNewCoolOffscreen.GetOffPort: CGrafPtr; OVERRIDE;
-
- BEGIN
- GetOffPort := CGrafPtr(fOffWorld);
- END;
-
- {--------------------------------------------------------------------------------------------------}
- {$S ARes}
-
- PROCEDURE TNewCoolOffscreen.PostDraw; OVERRIDE;
-
- BEGIN
- SELF.UnlockThePixels;
-
- INHERITED PostDraw;
- END;
-
- {--------------------------------------------------------------------------------------------------}
- {$S ARes}
-
- PROCEDURE TNewCoolOffscreen.SetupOffWorld; OVERRIDE;
-
- BEGIN
- SELF.LockThePixels;
- SetGWorld(fOffWorld, NIL);
- END;
-
- {--------------------------------------------------------------------------------------------------}
- {$S ARes}
-
- PROCEDURE TNewCoolOffscreen.LockThePixels;
-
- { Call 32-bit Color QuickDraw’s LockPixels routine to lock down the offscreen data
- structures. We ignore the result, because the only meaningful result (FALSE), means that
- LockPixels tried to re-allocate some purged structures, and failed. We don’t allow those
- structures to be purged (we specified that when we called NewGWorld), so it will never
- return FALSE for us. }
-
- BEGIN
- IF (fOffWorld <> NIL) & LockPixels(fOffWorld^.portPixMap) THEN;
- END;
-
- {--------------------------------------------------------------------------------------------------}
- {$S ARes}
-
- PROCEDURE TNewCoolOffscreen.UnlockThePixels;
-
- { Reverse the effect of LockThePixels. When we are drawing to the offscreen PixMap, we need
- its bit locked down so they don’t move around when we try to access them. But when our
- attention is elsewhere and we aren’t drawing to the offscreen world, we’d like them to
- float around in the heap, so as not to fragment it. This is OK with 32-bit Color QuickDraw
- it the data is unlocked when it’s not looking. }
-
- BEGIN
- IF fOffWorld <> NIL THEN
- UnlockPixels(fOffWorld^.portPixMap);
- END;
-
- {--------------------------------------------------------------------------------------------------}
- {$S AFields}
-
- PROCEDURE TNewCoolOffscreen.Fields(PROCEDURE DoToField(fieldName: Str255; fieldAddr: Ptr;
- fieldType: Integer)); OVERRIDE;
-
- BEGIN
- DoToField('TNewCoolOffscreen', NIL, bClass);
- DoToField('fOffWorld', @fOffWorld, bGrafPtr);
-
- INHERITED Fields(DoToField);
- END;
-